package com.aios.action.user.iris;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

import com.aios.entity.mapper.IrisUserHasUserGroups;
import com.aios.entity.unit.GenderEnum;

public class IrisUserViewAction extends AbstractIrisUserAction {

	private static final long serialVersionUID = 1L;

	private IrisUserHasUserGroups user;
	private List<String> registrationFlags;

	public String execute() {
		try {
			user = irisUserService.findByIdWithGroups(id);
			registrationFlags = new ArrayList<String>();
			// this.irisUser = findById();
			if(user.getIrisData().getLeftEye().equals("true")) {
				registrationFlags.add(getText("user.data.left.eye"));
			}
			if(user.getIrisData().getRightEye().equals("true")) {
				registrationFlags.add(getText("user.data.right.eye"));
			}
			if(user.getIrisData().getCard().equals("true")) {
				registrationFlags.add(getText("user.data.card"));
			}
			if(user.getIrisData().getPin().equals("true")) {
				registrationFlags.add(getText("user.data.pin"));
			}

			user.getIrisUser().setGender(GenderEnum.getMap(Locale.JAPAN).get(Integer.parseInt(user.getIrisUser().getGender())));

		} catch (Exception e) {
			// logger
			e.printStackTrace();
			addActionError(getText("error.user.notfound"));
			return INPUT;
		}

		return SUCCESS;
	}

	public IrisUserHasUserGroups getUser() {
		return user;
	}

	public void setUser(IrisUserHasUserGroups user) {
		this.user = user;
	}

	public List<String> getRegistrationFlags() {
		return registrationFlags;
	}

	public void setRegistrationFlags(List<String> registrationFlags) {
		this.registrationFlags = registrationFlags;
	}
	
}
